package org.apache.jsp.view.comprar.efetuadas;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import br.com.skpharma.vo.*;
import br.com.skpharma.dao.*;
import java.util.*;

public final class detalhe_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=iso-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\t\r\n");
      out.write("\t\r\n");
      out.write("\t<html>\r\n");
      out.write("\t<head>\r\n");
      out.write("\t");

		if(request.getParameter("voltar") != null){
			
      out.write("\r\n");
      out.write("\t\t\t<script language=\"javascript\">\r\n");
      out.write("\t\t\t\twindow.location.href=\"index.jsp\";\r\n");
      out.write("\t\t\t</script>\r\n");
      out.write("\t\t");

		}
	
	

	
      out.write("\r\n");
      out.write("\t<title></title>\r\n");
      out.write("\t<link href=\"../css/css.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
      out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><style type=\"text/css\">\r\n");
      out.write("\t<!--\r\n");
      out.write("\tbody {\r\n");
      out.write("\t\tmargin-left: 0px;\r\n");
      out.write("\t\tmargin-top: 0px;\r\n");
      out.write("\t\tmargin-right: 0px;\r\n");
      out.write("\t\tmargin-bottom: 0px;\r\n");
      out.write("\t}\r\n");
      out.write("\ta:link {\r\n");
      out.write("\t\tcolor: #000000;\r\n");
      out.write("\t\ttext-decoration: none;\r\n");
      out.write("\t}\r\n");
      out.write("\ta:visited {\r\n");
      out.write("\t\tcolor: #000000;\r\n");
      out.write("\t\ttext-decoration: none;\r\n");
      out.write("\t}\r\n");
      out.write("\ta:hover {\r\n");
      out.write("\t\tcolor: #000000;\r\n");
      out.write("\t\ttext-decoration: none;\r\n");
      out.write("\t}\r\n");
      out.write("\ta:active {\r\n");
      out.write("\t\tcolor: #000000;\r\n");
      out.write("\t\ttext-decoration: none;\r\n");
      out.write("\t}\r\n");
      out.write("\t.style1 {\r\n");
      out.write("\t\tcolor: #FFFFFF;\r\n");
      out.write("\t\tfont-weight: bold;\r\n");
      out.write("\t}\r\n");
      out.write("\t-->\r\n");
      out.write("\t</style>\r\n");
      out.write("\t<link href=\"../../css/css.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
      out.write("\t<style type=\"text/css\">\r\n");
      out.write("<!--\r\n");
      out.write(".style2 {color: #000000}\r\n");
      out.write("-->\r\n");
      out.write("    </style>\r\n");
      out.write("\t</head>\r\n");
      out.write("\t<body>\r\n");
      out.write("\t  \r\n");
      out.write("    <div align=\"left\">\r\n");
      out.write("      ");

		
	if (request.getParameter("venda") != null){
		int codvenda = (Integer.parseInt(request.getParameter("venda")));
		DAOItemVenda daoItemVenda = new DAOItemVenda();
		ArrayList lista3 = new ArrayList();
		lista3 = daoItemVenda.obterListaPorVenda(codvenda);
		System.out.println("TAMANHO ARRAY :" + lista3.size());
		
      out.write("\r\n");
      out.write("\t <table width=\"700\" border=\"0\" align=\"left\" cellpadding=\"5\" cellspacing=\"2\" bordercolor=\"#f2f2f2\" style=\"font-size:12px\">\r\n");
      out.write("\t <tr>\r\n");
      out.write("       <td width=\"42%\" bgcolor=\"#941C1D\"><p class=\"style1\">Modelo</p>       </td>\r\n");
      out.write("\t   <td width=\"10%\" bgcolor=\"#941C1D\"><span class=\"style1\">Conte&uacute;do</span></td>\r\n");
      out.write("\t   <td width=\"8%\" bgcolor=\"#941C1D\"><span class=\"style1\">Pre&ccedil;o</span></td>\r\n");
      out.write("\t   <td width=\"20%\" bgcolor=\"#941C1D\"><p class=\"style1\">Categoria</p></td>\r\n");
      out.write("\t   <td width=\"20%\" bgcolor=\"#941C1D\"><p class=\"style1\">Quantidade Comprada </p></td>\r\n");
      out.write("\t   </tr>\r\n");
      out.write("\t   <tr>\r\n");
      out.write("\t ");

	for (int i = 0; i<lista3.size(); i++){
	
		
		if	((((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getCategoriaVO().getCod() == 2){
		
      out.write("\r\n");
      out.write("     \r\n");
      out.write("        <tr>\r\n");
      out.write("          <td width=\"42%\" class=\"style2\">");
      out.print(((PrateleiraVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getModeloVO().getDs());
      out.write(' ');
      out.write('-');
      out.write(' ');
      out.print(((PrateleiraVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getModeloVO().getMarcaVO().getDs());
      out.write("</a></td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((PrateleiraVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getConteudo());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"8%\" class=\"style2\">");
      out.print(((PrateleiraVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getPreco());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((PrateleiraVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getCategoriaVO().getDs());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((ItemVendaVO)lista3.get(i)).getQtde());
      out.write("</td>\r\n");
      out.write("\t      </tr>\r\n");
      out.write("\t        \r\n");
      out.write("\t        \r\n");
      out.write("        ");
		
		} 
		else{
			
      out.write("\r\n");
      out.write("\t        \r\n");
      out.write("        <tr>\r\n");
      out.write("          <td width=\"42%\" class=\"style2\">");
      out.print(((MedicamentoVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getDs());
      out.write("</a></td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((MedicamentoVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getConteudo());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"8%\" class=\"style2\">");
      out.print(((MedicamentoVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getPreco());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((MedicamentoVO)((ItemVO)((ItemVendaVO)lista3.get(i)).getItemVO()).getProdutoVO()).getCategoriaVO().getDs());
      out.write("</td>\r\n");
      out.write("\t        <td width=\"20%\" class=\"style2\">");
      out.print(((ItemVendaVO)lista3.get(i)).getQtde());
      out.write("</td>\r\n");
      out.write("\t    </tr>\r\n");
      out.write("      ");
	
			
		}
		
	}
	
      out.write("\r\n");
      out.write("\t\t  \r\n");
      out.write("\t\t\r\n");
      out.write("\t\r\n");
      out.write("     \r\n");
      out.write("\t ");
} 
      out.write("\r\n");
      out.write("\t       \r\n");
      out.write("\t    </tr>\r\n");
      out.write("        </table>\r\n");
      out.write("\t       \r\n");
      out.write("    </div>\r\n");
      out.write("\t</body>\r\n");
      out.write("\t</html>\r\n");
      out.write("\t\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
